#include<bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    int cnt = n;
    stack<int> number;
    stack<char> op;
    // 数字入栈
    while (cnt--) {
        int num;
        cin >> num;
        number.push(num);
    }
    // 符号入栈
    cnt = n - 1;
    while (cnt--) {
        char ops;
        cin >> ops;
        op.push(ops);
    }

    while (op.size()) {
        int n1 = number.top();
        number.pop();
        int n2 = number.top();
        number.pop();
        char ops = op.top();
        op.pop();
        if (ops == '+') number.push(n2 + n1);
        else if (ops == '-') number.push(n2 - n1);
        else if (ops == '*') number.push(n2 * n1);
        else {
            if (n1 == 0) {
                cout << "ERROR: " << n2 << "/0" << endl;
                return 0;
            } else {
                number.push(n2 / n1);
            }
        }
    }
    
    cout << number.top() << endl;
    return 0;
}